<template>
  <div class="myteam-container">
    <div class="Individual_TOP BGType">
      <div class="Top_content_BL">
        <span :class="cut==='today'?'cut':''" @click="navClick('today')">日榜</span>
        <span :class="cut==='week'?'cut':''" @click="navClick('week')">周榜</span>
        <span :class="cut==='month'?'cut':''" @click="navClick('month')">月榜</span>
        <span :class="cut==='year'?'cut':''" @click="navClick('year')">年度</span>
      </div>
    </div>
    <div class="bg">
      <div class="ranking_toptow" v-if="toplist.length == 3">
        <ul>
          <li class="li1">
            <div class="img">
              <span>{{ toplist[1].userName }}</span>
              <p></p>
              <img :src="toplist[1].avatar == '' ? 'static/img/user.20010688.gif' : toplist[1].avatar" />
            </div>
            <div class="tabs">
              <p>
                <b>￥{{ toplist[1].allCommission }}</b>
                总业绩
                <span class="hr"></span>
              </p>
              <p>
                <b>{{ toplist[1].total }}</b>
                跑单量
              </p>
            </div>
          </li>
          <li class="li2">
            <p class="hr-l"></p>
            <p class="hr-r"></p>
            <div class="img">
              <span>{{ toplist[0].userName }}</span>
              <p></p>
              <img :src="toplist[0].avatar == '' ? 'static/img/user.20010688.gif' : toplist[0].avatar" />
            </div>
            <div class="tabs">
              <p>
                <b>￥{{ toplist[0].allCommission }}</b>
                总业绩
                <span class="hr"></span>
              </p>
              <p>
                <b>{{ toplist[0].total }}</b>
                跑单量
              </p>
            </div>
          </li>
          <li class="li3">
            <div class="img">
              <span>{{ toplist[2].userName }}</span>
              <p></p>
              <img :src="toplist[2].avatar == '' ? 'static/img/user.20010688.gif' : toplist[2].avatar" />
            </div>
            <div class="tabs">
              <p>
                <b>￥{{ toplist[2].allCommission }}</b>
                总业绩
                <span class="hr"></span>
              </p>
              <p>
                <b>{{ toplist[2].total }}</b>
                跑单量
              </p>
            </div>
          </li>
        </ul>
      </div>
      <el-row class="ranking_ullist" :gutter="20" style="margin: 0 auto;margin-bottom: 20px;" v-if="list.length >= 1">
        <el-col :span="6" v-for="(item, index) in list" :key="index">
          <div class="ranking_card">
            <div class="ranking_index">{{ index + 4 }}</div>
            <div class="ranking_avatar"><img :src="item.avatar == '' ? 'static/img/user.20010688.gif' : item.avatar" /></div>
            <div class="ranking_username">{{ item.userName }}</div>
            <div style="text-align: center;margin-top: 20px;">
              <div class="ranking_allmoney">
                <span class="ranking_allmoney_title">总业绩</span>
                <span class="ranking_allmoney_number">{{ item.allCommission }}元</span>
              </div>
            </div>
            <div class="ranking_paodan">
              <i class="el-icon-s-goods" style="font-size: 20px;"></i>
              跑单量:{{ item.total }}
            </div>
          </div>
        </el-col>
      </el-row>
      <div style="height: 100px;"></div>
    </div>
  </div>
</template>

<script>
import { listUserRanking } from '@/api/index';
export default {
  name: 'Myteam',
  components: {},
  data() {
    return {
      toplist: [],
      list: [],
      cut:'today'
    };
  },
  created() {
    this.getList();
  },
  mounted() {},
  methods: {
    navClick(index){
      if(this.cut === index){
        return false;
      }
      this.cut = index
      this.getList();
    },
    getList(){
      listUserRanking({type:this.cut}).then(res => {
        this.toplist = []
        this.list = []
        if (res.data.length >= 3) {
          for (let i = 0; i < res.data.length; i++) {
            if (i < 3) {
              this.toplist.push(res.data[i]);
            } else {
              this.list.push(res.data[i]);
            }
          }
        } else {
          this.$alert('暂无榜单数据', '标题名称', {
            confirmButtonText: '确定',
            callback: action => {
              //this.$router.back();
            }
          });
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.myteam-container {
  .bg {
    background: url(https://img.alicdn.com/imgextra/i4/2697264884/O1CN01AwXLao1lwuz8VBhTy_!!2697264884.jpg) center top no-repeat #260049;
    position: relative;
    z-index: 0;
    .ranking_toptow {
      max-width: 1060px;
      height: 325px;
      margin: auto auto 40px;
      padding-top: 10px;
      li:hover {
        background: #f7eeff;
      }
      li {
        float: left;
        width: 33.2%;
        position: relative;
        z-index: 2;
        background: #fff;
        padding-bottom: 15px;
        list-style-type: none;
        .tabs {
          height: 50px;
          line-height: 30px;
          font-size: 14px;
          margin-top: 20px;
          color: #333c48;
          p {
            float: left;
            width: 50%;
            text-align: center;
            position: relative;
            z-index: 0;
          }
          b {
            color: #fc9f1f;
            font-size: 20px;
            display: block;
          }
          .hr {
            width: 1px;
            height: 50px;
            background: #eee;
            position: absolute;
            right: 0;
            top: 0;
            z-index: 1;
          }
        }
        .img {
          height: 180px;
          display: block;
          width: 176px;
          position: relative;
          overflow: hidden;
          margin: auto;
          top: 55px;
          span {
            height: 32px;
            text-align: center;
            z-index: 50;
            bottom: 0;
            position: absolute;
            width: 100%;
            display: block;
            font-size: 14px;
            color: #496b87;
          }
          p {
            background: url(https://img.alicdn.com/imgextra/i3/2697264884/O1CN01N7u7ON1lwuz8hrz73_!!2697264884.png) -352px 0;
            width: 176px;
            height: 165px;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 10;
          }
          img {
            width: 110px;
            display: block;
            margin: auto;
            position: relative;
            top: 30px;
            z-index: 0;
          }
        }
      }
      li.li1 {
        border-radius: 20px 0 0 20px;
        top: 50px;
        height: 250px;
        cursor: pointer;
        .img {
          top: 0;
          height: 160px;
          img {
            width: 100px;
            top: 30px;
          }
        }
      }
      li.li1:hover {
        .img {
          p {
            background-position: -352px -176px;
          }
        }
      }
      li.li2 {
        border-radius: 20px 20px 0 0;
        z-index: 5;
        height: 300px;
        cursor: pointer;
        .img {
          top: 20px;
          margin-bottom: 45px;
          height: 165px;
          span {
            bottom: 5px;
            color: #786612;
          }
        }
        .hr-l {
          position: absolute;
          left: -6px;
          top: 50px;
          width: 6px;
          height: 180px;
          background: url(https://img.alicdn.com/imgextra/i3/2697264884/O1CN018JeKSP1lwuzCvn99B_!!2697264884.png) no-repeat;
        }
        .hr-r {
          position: absolute;
          left: auto;
          right: -6px;
          top: 60px;
          width: 6px;
          height: 180px;
          background: url(https://img.alicdn.com/imgextra/i2/2697264884/O1CN01XmWnFs1lwuz7hfyNM_!!2697264884.png) no-repeat;
        }
        .img {
          p {
            background-position: 0 0;
          }
        }
      }
      li.li2:hover {
        .img {
          p {
            background-position: 0 -176px;
          }
        }
      }
      li.li3 {
        border-radius: 0 20px 20px 0;
        top: 60px;
        height: 240px;
        cursor: pointer;
        .img {
          top: 0;
          height: 150px;
          p {
            background-position: -176px 0;
          }
          span {
            bottom: 2px;
            color: #855125;
          }
          img {
            width: 90px;
            top: 35px;
          }
        }
      }
      li.li3:hover {
        .img {
          p {
            background-position: -176px -176px;
          }
        }
      }
    }
    .ranking_ullist {
      background: url(https://img.alicdn.com/imgextra/i1/2697264884/O1CN01BVkvF31lwuzCvkavS_!!2697264884.jpg) center center;
      max-width: 1090px;
      border-radius: 10px;
      padding: 10px 0px;
      margin: auto;
      .ranking_card:hover {
        background: #f7eeff;
      }
      .ranking_card {
        padding: 0px;
        padding-top: 20px;
        position: relative;
        border-radius: 5px;
        background-color: #ffffff;
        margin: 10px auto;
        cursor: pointer;
        .ranking_index {
          position: absolute;
          top: 0px;
          left: 12px;
          width: 40px;
          height: 40px;
          color: #fff;
          font-size: 26px;
          font-weight: bold;
          line-height: 38px;
          text-align: center;
          background: #353bae;
          font-family: DINBlack;
          border-bottom-left-radius: 10px;
          border-bottom-right-radius: 10px;
          box-shadow: 0px 4px 8px 0px rgba(36, 41, 140, 0.3);
        }
        .ranking_avatar {
          width: 100%;
          height: 90px;
          text-align: center;
          img {
            width: 82px;
            height: 82px;
            border-radius: 50%;
            border: 3px solid #3c43b8;
            box-shadow: 0px 12px 15px -8px rgba(43, 47, 155, 0.25);
          }
        }
        .ranking_username {
          width: 100%;
          font-size: 16px;
          color: #353bae;
          font-weight: bold;
          text-align: center;
          margin-top: 19px;
        }
        .ranking_allmoney {
          display: inline-flex;
          justify-content: space-between;
          min-width: 180px;
          height: 30px;
          line-height: 30px;
          margin: 0 auto;
          background: linear-gradient(90deg, rgba(254, 84, 85, 1) 0%, rgba(238, 11, 11, 1) 100%);
          border-radius: 15px;
          .ranking_allmoney_title {
            flex-grow: 1;
            color: #fff;
            font-size: 14px;
            padding: 0 6px 0 12px;
            font-weight: bold;
          }
          .ranking_allmoney_number {
            flex-grow: 1;
            padding: 0 6px 0 10px;
            height: 28px;
            line-height: 28px;
            margin-top: 1px;
            margin-right: 1px;
            background-color: #fff;
            background-image: url(https://img.alicdn.com/imgextra/i2/2697264884/O1CN01LqtiWb1lwuzBHFhvP_!!2697264884.png);
            background-position: 0 0;
            background-size: 8px 28px;
            background-repeat: no-repeat;
            color: #ee0b0c;
            font-size: 16px;
            font-weight: bold;
            border-top-right-radius: 15px;
            border-bottom-right-radius: 15px;
          }
        }
        .ranking_paodan {
          margin-top: 20px;
          text-align: center;
          height: 40px;
          font-weight: bold;
          line-height: 40px;
          font-size: 16px;
          color: #353bae;
        }
      }
    }
  }
  .Individual_TOP {
    position: relative;
    margin: 0 auto;
    height: 300px;
    background-image: url(https://img.alicdn.com/imgextra/i4/2697264884/O1CN01AwXLao1lwuz8VBhTy_!!2697264884.jpg);
    .Top_content_BL {
        position: absolute;
        bottom: 0px;
        left: calc(50% + 265px);
        width: 308px;
        height: 36px;
        cursor:pointer
    }
    span{
      line-height: 36px;width: 70px;display:block;float:left;text-align: center;font-size: 16px;font-weight: bold;
      background-color: #ffedde;
      border-top-left-radius: 5px;
      border-top-right-radius: 5px;
      margin: 0 2px;
    }
    .cut{
      background-color: #1890FF;
      color: #FFFFFF;
    }
  }
  .BGType {
    background-repeat: no-repeat;
    background-clip: border-box;
    background-origin: padding-box;
    background-size: auto;
    background-position: center;
  }
}
</style>
